<%page expression_filter="h"/>

<%!
from django.urls import reverse
from django.utils.translation import gettext as _

from openedx.core.djangolib.js_utils import js_escaped_string, dump_js_escaped_json
%>

<%inherit file="../main.html"/>
<%namespace file='../main.html' import="login_query"/>
<%namespace name='static' file='../static_content.html'/>

<%block name="title">
    <title>
        ${_("Contact {platform_name} Support").format(platform_name=platform_name)}
    </title>
</%block>

<%block name="head_extra">
    <link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</%block>

<%block name="body">

    <div id="root" class="container">
    </div>

    <%static:webpack entry="SingleSupportForm">
        var context = {
            'platformName': "${platform_name | n, js_escaped_string}",
            'marketingUrl': "${marketing_link('FAQ') | n, js_escaped_string}",
            'loginQuery': "${login_query() | n, js_escaped_string}",
            'dashboardUrl': "${reverse('dashboard') | n, js_escaped_string}",
            'homepageUrl': "${marketing_link('ROOT') | n, js_escaped_string}",
            'submitFormUrl': "${reverse('zendesk_proxy_v1') | n, js_escaped_string}",
            'customFields': ${custom_fields | n, dump_js_escaped_json},
            'tags': ${tags | n, dump_js_escaped_json},
            'supportEmail': "${support_email | n, js_escaped_string}",
        }

        % if user.is_authenticated:
            context['user'] = {
                'fullName': "${user.profile.name | n, js_escaped_string}",
                'username': "${user.username | n, js_escaped_string}",
                'email': "${user.email | n, js_escaped_string}",
                'course_id': "${course_id | n, js_escaped_string}"
            }

            % if user_enrollments:
                enrollments = []
                % for enrollment in user_enrollments:
                    % if enrollment.course_overview:
                        enrollments.push({
                            'course_id': "${enrollment.course_overview.id | n, js_escaped_string}",
                            'course_name': "${enrollment.course_overview.display_name | n, js_escaped_string}",
                        })
                    % endif
                %endfor
                context['user']['enrollments'] = enrollments

            % endif

        % endif

        new SingleSupportForm(context);
    </%static:webpack>
</%block>
